﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using SoGame.ViewModels;
using System.Windows;

namespace SoGame.Helper
{
    public class FacebookStatusToVisibilityConverter : IValueConverter
    {
        public FacebookStatusToVisibilityConverter() { }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FacebookStatus bValue = (FacebookStatus)value;
            if (parameter != null && (parameter as string) != null && (parameter as string) == "false")
            {
                if (FacebookStatus.Connected == bValue)
                {
                    return Visibility.Collapsed;
                }
                else
                {
                    return Visibility.Visible;
                }
            }

            if (FacebookStatus.Connected == bValue)
            {
                return Visibility.Visible;
            }
            else
            {
                return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FacebookStatus visibility = (FacebookStatus)value;

            if (visibility == FacebookStatus.Connected)
                return true;
            else
                return false;
        }
    }
}
